﻿using Config;
using gfLibrary;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBUtility;

namespace IYAKASAPortal.LabourVerify
{
    public partial class VehicleDD : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                BindData();
            }
        }

        protected void BindData()
        {
            string strSql = "select ID,HPHM,HPZL,HPZLDH,JCXH,GWBH,JCZT_STATUS,JYXM FROM VEHICLE_DISPATCH where JCZT_STATUS not in ('0','4') and jcxh is not null ";
            string strCount = "select count(*) FROM VEHICLE_DISPATCH WHERE JCZT_STATUS NOT IN ('0','4') ";

            strSql += " order by JCXH ASC";

            DataTable m_dtTable = new DataTable();
            GreatPager1.BindDataTablePage(ref m_dtTable, AppConfig.g_strConnectionStringSqlClient, strSql, 20);

            rptList.DataSource = m_dtTable;
            rptList.DataBind();

            m_dtTable.Dispose();

            string count = DbHelper.GetValue(strCount);
            lblRecord.Text = count; 
        }

        protected void GreatPager1_PageIndexChanging(object sender, gfPage.PagerEventArgs e)
        {
            GreatPager1.PageIndex = e.NewPageIndex;

            DataTable m_dtTable = GreatPager1.BindDataTablePage();
            rptList.DataSource = m_dtTable;
            rptList.DataBind();
        }

        protected void Timer1_Tick(object sender, EventArgs e)
        {
            BindData();
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "xxxe", "getColor()", true);
        }

        protected string getJCXM(string jcxm)
        {
            string result = "";
            if (!string.IsNullOrEmpty(jcxm))
            {
                string temp = jcxm.Substring(0, jcxm.Length - 1);
                if (temp.IndexOf(',') > 0)
                {
                    var item = temp.Split(',');
                    foreach (var i in item)
                    {
                        result += getXMName(i.ToString())+"、";
                    }
                }
                else
                {
                    result = getXMName(temp) + "、";
                }
            }
            return result.Substring(0,result.Length-1);
        }

        protected string getXMName(string xm)
        {
            string result = "";
            result= DbHelper.GetValue("SELECT CON_CON from const_define where CON_CHNAME='jyxm' and CON_CODE='" + xm + "'");
            return result;
        }

        protected string getCheckS(string status)
        {
            string result = "";
            if (status == "1")
            {
                result = "在检";
            }
            else if(status=="2" || status=="3")
            {
                result = "已检";
            }
            return result;
        }

        protected string getCheckJ(string status)
        {
            string result = "";
            if (status == "2")
            {
                result = "在检";
            }
            else if (status == "3")
            {
                result = "已检";
            }
            return result;
        }

        protected string getCheckX(string status)
        {
            string result = "";
            if (status == "3")
            {
                result = "在检";
            }
            return result;
        }
    }
       
}